from django import forms

from common.models import User


class RegisterForm(forms.ModelForm):

    repassword = forms.CharField(max_length=20)
    code = forms.CharField(min_length=6, max_length=6)

    def clean_username(self):
        pass

    def clean_real_name(self):
        pass

    def clean_repassword(self):
        form_data = super().clean()
        if form_data['password'] != form_data['repassword']:
            raise forms.ValidationError('密码和确认密码不一致')

    class Meta:
        model = User
        fields = ('username', 'password', 'real_name', 'tel')
